import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 维修分类信息 */
export interface MaintenanceClassification {
  id: number // 分类id
  name?: string // 分类名称
  status?: number // 状态
  description?: string // 描述
}

// 维修分类 API
export const MaintenanceClassificationApi = {
  // 查询维修分类分页
  getMaintenanceClassificationPage: async (params: any) => {
    return await request.get({ url: `/business/maintenance-classification/page`, params })
  },

  // 查询所有维修分类
  getMaintenanceClassificationList: async (params: any) => {
    return await request.get({ url: `/business/maintenance-classification/list`, params })
  },

  // 查询维修分类详情
  getMaintenanceClassification: async (id: number) => {
    return await request.get({ url: `/business/maintenance-classification/get?id=` + id })
  },

  // 新增维修分类
  createMaintenanceClassification: async (data: MaintenanceClassification) => {
    return await request.post({ url: `/business/maintenance-classification/create`, data })
  },

  // 修改维修分类
  updateMaintenanceClassification: async (data: MaintenanceClassification) => {
    return await request.put({ url: `/business/maintenance-classification/update`, data })
  },

  // 删除维修分类
  deleteMaintenanceClassification: async (id: number) => {
    return await request.delete({ url: `/business/maintenance-classification/delete?id=` + id })
  },

  /** 批量删除维修分类 */
  deleteMaintenanceClassificationList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/maintenance-classification/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出维修分类 Excel
  exportMaintenanceClassification: async (params) => {
    return await request.download({
      url: `/business/maintenance-classification/export-excel`,
      params
    })
  },

  // 下载导入模板
  importEqupmentTemplate: async () => {
    return request.download({ url: '/business/maintenance-classification/get-import-template' })
  }
}
